package com.zyj.spring.annotationaop.dao;

import com.zyj.spring.annotationaop.model.User;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

@Repository
public class UserDao {

    private Map<Long, User> fakeUsers;

    @PostConstruct
    private void init() {
        fakeUsers = new HashMap<>(2 << 2);
        fakeUsers.put(1L, User.builder().id(1L).name("张三").build());
        fakeUsers.put(2L, User.builder().id(2L).name("李四").build());
        fakeUsers.put(3L, User.builder().id(3L).name("王五").build());
        fakeUsers.put(4L, User.builder().id(4L).name("赵六").build());
        fakeUsers.put(5L, User.builder().id(5L).name("小石").build());
    }

    public User selectOne(Long id) {
        return fakeUsers.get(id);
    }

}
